<?php

/**
 * Description of Section_model
 *
 */
class Category_model extends CI_Model {

//put your code here
    function __construct() {
        parent::__construct();
    }

    /**
     * @desc Get ALL section
     * @param <array> $arrParams('sectionid')
     * @return <array> data if success else NULL or error
     */
    function sec_GetALLCategory($arrParams) {
        try {
            $this->db->select('*');
            $this->db->from('categories');
            $this->db->where(array('level' => 1));
            $this->db->where(array('path <> "uncategorised"' => NULL, 'path IS NOT NULL' => NULL));
            $query = $this->db->get();
            return $query->result();
        } catch (Exception $e) {
            print_r($e);
        }
    }
    
    function sec_GetCategoryByParrent($arrParams) {
        try {
            $this->db->select('*');
            $this->db->from('categories');
            if (!empty($arrParams)) {
                $this->db->where(array('parent_id' => $arrParams['catid']));
            }
            $query = $this->db->get();
            return $query->result();
        } catch (Exception $e) {
            print_r($e);
        }
    }
}

?>
